import { createI18n } from 'vue-i18n';
import en from './locales/en.json';
import zh from './locales/zh.json';
import hi from './locales/hi.json';
import de from './locales/de.json';
import ru from './locales/ru.json';
import es from './locales/es.json';
import it from './locales/it.json';
import ja from './locales/ja.json';
import fr from './locales/fr.json';
import pt from './locales/pt.json';
import ar from './locales/ar.json';
// 定义中英文语言包
const messages = {
  en,
  zh,
  hi,
  de,
  ru,
  es,
  it,
  ja,
  fr,
  pt,
  ar
};

// 获取本地存储中的语言设置，如果没有则默认使用中文
const locale = localStorage.getItem('locale') || 'zh';

const i18n = createI18n({
  locale,
  fallbackLocale: 'zh',
  messages,
});

export default i18n;